package com.example.demo.behavior.strategy;

/**
 * @Desc:
 * @Author zzz
 * @Date 2021/2/20
 * @Version V1.0
 */
public enum  PaymentEnum {

    ALIPAY("Alipay", new AliPay()),
    WECHAT("WeChat", new WeChatPay()),
    YINLIAN("YinLian", new YinLianPay());

    private String payWay;
    private Payment payment;

    PaymentEnum(String payWay, Payment payment) {
        this.payWay = payWay;
        this.payment = payment;
    }

    public static Payment load(String payWay) {
        PaymentEnum[] values = PaymentEnum.values();
        for (PaymentEnum value : values) {
            if (payWay.equals(value.payWay)) {
                return value.payment;
            }
        }
        return null;
    }

}
